package com.jse.enhance.jdk7.nio2;

import org.junit.Test;

import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * @author : zenghua
 * @version : v0.1 PathTest.java
 * @since : 2018/3/26 16:52
 */
public class PathTest {

	@Test
	public void testPath() {
//		File file = new File("D:\\opensource\\oschina\\re-javase\\src\\main\\java\\com\\jse\\enhance\\jdk7\\nio2\\PathTest.java");
//		Path path = file.toPath();

		Path path = Paths.get("D:\\opensource\\oschina\\re-javase\\src\\main\\java\\com\\jse\\enhance\\jdk7\\nio2\\PathTest.java");
		System.out.format("toString: %s%n", path.toString());
		System.out.format("getFileName: %s%n", path.getFileName());
		System.out.format("getName(0): %s%n", path.getName(0));
		System.out.format("getNameCount: %d%n", path.getNameCount());
		System.out.format("subpath(0,2): %s%n", path.subpath(0,2));
		System.out.format("getParent: %s%n", path.getParent());
		System.out.format("getRoot: %s%n", path.getRoot());

		//文件路径连接
		Path p1 = Paths.get("D:\\opensource\\oschina");
// Result is C:\home\joe\foo\bar
//		System.out.format("%s%n", p1.resolve("bar"));
		System.out.println(p1.resolve("re-javase"));
	}

	@Test
	public void testFiles() {
//		Files.
	}
}
